package com.lp.article.config;

import com.lp.model.constants.MQConstants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MQCommentConfig {

    @Bean
    public DirectExchange commentDirectExchange() {
        return new DirectExchange(MQConstants.COMMENT_EXCHANGE_DIRECT, true, false);
    }

    @Bean
    public Queue commentIncrOrDecrQueue() {
        return new Queue(MQConstants.COMMENT_INCR_OR_DECR_QUEUE, true);
    }


    @Bean
    public Binding commentIncrOrDecrBind() {
        return BindingBuilder.bind(commentIncrOrDecrQueue()).to(commentDirectExchange())
                .with(MQConstants.COMMENT_INCR_OR_DECR_QUEUE);
    }

}
